const db = wx.cloud.database()
Page({
  data: {
    //轮播图
    swiperCurrent: 1,
    turturns: [], //轮番图
    indicatorDots: true,
    autoplay: true,
    interval: 2000,
    duration: 1000,
    circular: true,
    //云数据——Text
    Text:[],
    //导航啦图标
    icons: [{
        name: '预约',
        icon: 'https://636c-cloud2-9gomot6xb9909364-1305292962.tcb.qcloud.la/index/yuyue.png?sign=bdba8b547c528c163b9849b7b0f4dd5d&t=1640864021'
      },
      {
        name: '导航',
        icon: 'https://636c-cloud2-9gomot6xb9909364-1305292962.tcb.qcloud.la/index/icons/App%20Icon%20OneDrive.png?sign=bfadd121d29a166931f632d64c841fec&t=1640774716'
      },
      {
        name: '导航',
        icon: 'https://636c-cloud2-9gomot6xb9909364-1305292962.tcb.qcloud.la/index/icons/App%20Icon%20Home.png?sign=e9102866a60e97f0e7777f06154a0d0b&t=1640774736'
      },
      {
        name: '导航',
        icon: 'https://636c-cloud2-9gomot6xb9909364-1305292962.tcb.qcloud.la/index/icons/App%20Icon%20Figma.png?sign=a699aaa652fbd802821cdba8ab85c2a1&t=1640774753'
      },
      {
        name: '导航',
        icon: 'https://636c-cloud2-9gomot6xb9909364-1305292962.tcb.qcloud.la/index/icons/App%20Icon%20DayOne.png?sign=d3d3a295fdc439ed8cc2954f4eb4306e&t=1640774769'
      },
    ]
  },
    //生命周期函数--监听页面加载
  onLoad: function (options) {
    //云数据库调用函数
    db.collection('index').where({
        _openid: 'turn_image'
      })
      .get({
        success: res => {
          this.setData({
            turturns: res.data,
          })
          //console.log('轮番图',res)
        }
      }),
      db.collection('index').where({
        _openid: 'text'
      }).get({success: res => {
          this.setData({
            Text: res.data,
          })
          //console.log('Text',res.data)
        }})
  },
  swiperChange: function (e) {
    this.setData({
      swiperCurrent: e.detail.current //获取当前轮播图片的下标
    })
  },
  //滑动图片切换  
  chuangEvent: function (e) {
    this.setData({
      swiperCurrent: e.currentTarget.id
    })
  },
  // 功能跳转函数
  clickon:function(e){
    var id=e.currentTarget.dataset.id
    //console.log('id',id)
    switch(id){
      case 0:wx.navigateTo({url: '/zpages/orders/orders',});break;
      case 1:wx.navigateTo({url: '/zpages/Tabs/Tabs',});break;
      case 2:wx.navigateTo({url: '/views/index/index',});break;
    }
  }
})